/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.dds2.ServicesSystem.Modelo;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Carlos Asis
 */
@Entity
@Table(name = "usersystem")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Usersystem.findAll", query = "SELECT u FROM Usersystem u"),
    @NamedQuery(name = "Usersystem.findById", query = "SELECT u FROM Usersystem u WHERE u.id = :id"),
    @NamedQuery(name = "Usersystem.findByName", query = "SELECT u FROM Usersystem u WHERE u.name = :name"),
    @NamedQuery(name = "Usersystem.findByFirstname", query = "SELECT u FROM Usersystem u WHERE u.firstname = :firstname"),
    @NamedQuery(name = "Usersystem.findByLastname", query = "SELECT u FROM Usersystem u WHERE u.lastname = :lastname"),
    @NamedQuery(name = "Usersystem.findByAddress", query = "SELECT u FROM Usersystem u WHERE u.address = :address"),
    @NamedQuery(name = "Usersystem.findByPhone", query = "SELECT u FROM Usersystem u WHERE u.phone = :phone"),
    @NamedQuery(name = "Usersystem.findByMail", query = "SELECT u FROM Usersystem u WHERE u.mail = :mail"),
    @NamedQuery(name = "Usersystem.findByPassword", query = "SELECT u FROM Usersystem u WHERE u.password = :password")})
public class Usersystem implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "name")
    private String name;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 40)
    @Column(name = "firstname")
    private String firstname;
    @Size(max = 40)
    @Column(name = "lastname")
    private String lastname;
    @Size(max = 45)
    @Column(name = "address")
    private String address;
    // @Pattern(regexp="^\\(?(\\d{3})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$", message="Invalid phone/fax format, should be as xxx-xxx-xxxx")//if the field contains phone or fax number consider using this annotation to enforce field validation
    @Size(max = 45)
    @Column(name = "phone")
    private String phone;
    @Size(max = 45)
    @Column(name = "mail")
    private String mail;
    @Size(max = 45)
    @Column(name = "password")
    private String password;
    @JoinColumn(name = "idPerfil", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Profile idPerfil;
    @JoinColumn(name = "idclass", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Typeclass idclass;

    public Usersystem() {
    }

    public Usersystem(Integer id) {
        this.id = id;
    }

    public Usersystem(Integer id, String name, String firstname) {
        this.id = id;
        this.name = name;
        this.firstname = firstname;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getFirstname() {
        return firstname;
    }

    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    public String getLastname() {
        return lastname;
    }

    public void setLastname(String lastname) {
        this.lastname = lastname;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getMail() {
        return mail;
    }

    public void setMail(String mail) {
        this.mail = mail;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Profile getIdPerfil() {
        return idPerfil;
    }

    public void setIdPerfil(Profile idPerfil) {
        this.idPerfil = idPerfil;
    }

    public Typeclass getIdclass() {
        return idclass;
    }

    public void setIdclass(Typeclass idclass) {
        this.idclass = idclass;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Usersystem)) {
            return false;
        }
        Usersystem other = (Usersystem) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return id+"";
    }
    
}
